package com.xichen.dao;

import com.github.pagehelper.Page;
import com.xichen.pojo.User;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.Mapper;

/**
 * @author tang wei
 * @version 1.0
 * @date 2020/7/16 13:49
 */
@Repository
public interface UserMapper extends Mapper<User> {//CONCAT('%',CONCAT(#{name},'%'))
    @Select("<script>"+"select * from sys_user where userRole!=1" +
            "<if test='queryUsername != null and queryUsername.length &gt; 0'> and username like concat('%',#{queryUsername},'%')</if>" +
            "<if test='queryTel != null and queryTel.length &gt; 0' > and tel like concat('%',#{queryTel},'%')</if></script>")
    Page<User> findByCondition(@Param("queryUsername") String queryUsername,@Param("queryTel") String queryTel);

    @Select("<script>"+"select * from sys_user where id!=#{id} and loginName=#{loginName}</script>")
    User findUserByLoginNameAndNotEqualId(@Param("loginName") String loginName,@Param("id") Long id);
}
